export const KEY = "cateLists";

// 设置
export function setItem(arr) {
    // arr是合并的数组
    sessionStorage.removeItem(KEY)
    sessionStorage.setItem(KEY,JSON.stringify(arr));
}

//获取
export function getItem() {
  var jsonString = sessionStorage.getItem(KEY);
  jsonString = jsonString || '[]';
  return JSON.parse(jsonString);
} //对象格式

export function remoteItem(key) {
  var arr = getItem();
  for (var i = arr.length - 1; i >= 0; i--) {
    if (arr[i].id == key) {
      arr.splice(i, 1);
    }
  }
    sessionStorage.setItem(KEY, JSON.stringify(arr));
}



